package com.zgl.modules.user.controller;

import com.zgl.feign.entity.MailEntity;
import com.zgl.feign.service.FeignMessageService;
import com.zgl.modules.user.DTO.MailDTO;
import com.zgl.modules.user.DTO.UserDTO;
import com.zgl.modules.user.entity.CodeEntity;
import com.zgl.modules.user.entity.User;

import com.zgl.modules.user.service.UserService;
import com.zgl.modules.user.service.impl.CodeServiceImpl;
import com.zgl.modules.user.service.impl.UserServiceImpl;
import com.zgl.modules.wallet.entity.WalletEntity;
import com.zgl.modules.wallet.service.impl.WalletServiceImpl;
import com.zgl.utils.Params;
import com.zgl.utils.R;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.UUID;
import java.util.concurrent.TimeUnit;

@Controller
@Api(tags = "用户注册操作")
@RequestMapping("/register")
public class RegisterController {


    @Autowired
    private UserServiceImpl userService;
    @Autowired
    private CodeServiceImpl codeService;
    @PostMapping("/getcode")
    @ResponseBody
    @ApiOperation(value = "通过邮箱获取验证")
    public R getcode(@RequestBody Params<MailDTO> params){
       return codeService.getcode(params.getParams().getEmail());
    }
    @PostMapping("/doregister")
    @ResponseBody
    @ApiOperation(value = "用户注册接口")
    public R register(@RequestBody Params<UserDTO> params){
       return userService.register(params.getParams());
}
}
